<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=utf-8" pageEncoding="utf-8"
	language="java"%>
<%@ include file="/jsp/platform/include/include.jsp"%>
<html>
<head>
<style type="text/css">
	/*兼容各浏览器*/
	:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
		color: #f00;
	}

	::-moz-placeholder { /* Mozilla Firefox 19+ */
		color: #f00;
	}

	input:-ms-input-placeholder,
	textarea:-ms-input-placeholder {
		color: #f00;
	}

	input::-webkit-input-placeholder,
	textarea::-webkit-input-placeholder {
		color: #f00;
	}
</style>
<TITLE><c:out value="${_LOGONUSER_.MANAGETITILE}" /></TITLE>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<%@ include file="/jsp/platform/include/header.jsp"%>

	<script type="text/javascript">

		function resetForm() {
			document.agentInfoForm.reset();
		}
		function editAgentInfo() {
			var _agentType = $("#agentType").val();
			var checkStr = "need|agentLevel|代理等级|" + $("#agentLevel").val()
					+ ";" + "need|agentType|代理类型|" + $("#agentType").val()
					+ ";" + "need|contacts|联系人|" + $("#contacts").val() + ";"
					+ "need|mobilephone|手机|" + $("#mobilephone").val() + ";"
					+ "phone|telephone|联系电话|" + $("#telephone").val() + ";"
					+ "email|email|邮箱|" + $("#email").val() + ";"
					+ "need|sysAccount|系统账号|" + $("#sysAccount").val() + ";"
//					+ "need|sysPassword|登陆密码|" + $("#sysPassword").val() + ";"
//					+ "need|depositBank|分润结算银行|" + $("#depositBank").val()
//					+ ";" + "need|depositBankbranch|结算支行|"
//					+ $("#depositBankbranch").val() + ";"
//					+ "need|bankUsrname|开户名|" + $("#bankUsrname").val() + ";"
//					+ "need|bankAccount|账户|" + $("#bankAccount").val() + ";"
					+ "need|bussBegindate|运营起始时间|" + $("input[name='bussBegindate']").val() + ";"
				    + "need|bussEnddate|运营终止时间|" + $("input[name='bussEnddate']").val()
//					+ ";" + "domain|sysPassword|登录密码|"
//					+ $("#sysPassword").val() + "|6,18;"

			if (_agentType == '1') {
				checkStr = checkStr+
				"need|agentName|代理名称|" + $("#agentName").val() + ";"
						+ "need|identityNo|证件号|" + $("#identityNo").val() + ";"
			} else if (_agentType == '2') {
				checkStr = checkStr+
				"need|companyName|公司名称|" + $("#companyName").val() + ";"
						+ "need|companyShortName|公司简称|"
						+ $("#companyShortName").val() + ";"
			}
			//检验唯一性
			if (!checkAll(checkStr)) {
				return false;
			}

			$.messager.confirm("操作提示", "您确定要执行此操作吗！", function(data) {
				if (data) {
               /*     var options = {
                        dataType:'json',
                        success: function (data) {
                            showMessage(data.msg);
                        },
						error:function (data) {
							showNetErrorMessage(data);
                        }
                    };
                    $("#agentInfoForm").ajaxSubmit(options);
                    return false;*/

					$("#agentInfoForm").submit();

				}
			});
		}
	</script>
</HEAD>
<BODY>
	<DIV class="all">
		<%@ include file="/jsp/platform/include/head.jsp"%>
		<%@ include file="/jsp/platform/include/menu.jsp"%>
		<DIV class="mains">
			<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
				<TBODY>
					<TR valign="top">
						<%@ include file="/jsp/platform/include/mainLeft.jsp"%>
						<TD>
							<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
								<TBODY>
									<TR>
										<TD>
											<TABLE width="180" border="0" cellspacing="0" cellpadding="0">
												<TBODY>
													<TR>
														<TD width="7"><IMG width="7" height="36" alt=""
															src="<%=request.getContextPath()%>/images/pages_l.jpg">
														</TD>
														<TD align="center"
															background="<%=request.getContextPath()%>/images/pages_bg.jpg">
															<SPAN class="f_tit1">新增代理信息
														</SPAN></TD>
														<TD width="7"><IMG width="7" height="36" alt=""
															src="<%=request.getContextPath()%>/images/pages_r.jpg">
														</TD>
													</TR>
												</TBODY>
											</TABLE></TD>
									</TR>
								</TBODY>
								<TR>
									<TD>
										<div class="pages_con">
											<FORM name="agentInfoForm" id="agentInfoForm"
												action="<%=request.getContextPath()%>/manage/agentInfo/saveOrUpdateAgentInfo"
												method="post" enctype="multipart/form-data">
												<DIV class="transaction_external">
													<DIV class="clearfix">
														<SPAN class="label cz_label "
															style="width: 120px; text-align: right;">代理等级：</SPAN> <SPAN
															class="label dl_w"
															style="padding-left: 0px; text-align: center; height: 30px; width: 230px;">
															<select id="agentLevel" name="agentLevel"
															value="<c:out value='${agentInfoModel.agentLevel}'/>">
																<option value="">请选择</option>
																 <c:forEach var="roleModel" items="${roleList}">
																	 <option value="${roleModel.roleId}">${roleModel.roleName}</option>
																 </c:forEach>
														</select> </SPAN><span class="reds f_l">*</span> <SPAN
															class="label cz_label "
															style="width: 120px; text-align: right;">代理类型：</SPAN> 
															<SPAN
															class="label dl_w"
															style="padding-left: 0px; text-align: center; height: 30px; width: 230px;"><select
															id="agentType" name="agentType"
															value="<c:out value='${agentInfoModel.agentType}'/>">
															<option value="">请选择</option>
															<option value="1">个人</option>
															<option value="2">企业</option>
														</select></SPAN><span class="reds f_l">*</span>
													</DIV>
													<DIV class="clearfix"></DIV>
													<DIV class="clearfix" id="companyInfo">
														<SPAN class="label cz_label "
															style="width: 120px; text-align: right;">公司名称：</SPAN> <input
															type="hidden" id="agentId" name="agentId"
															value="<c:out value='${agentInfoModel.agentId}'/>">
															<input type="hidden" id="operatorId"
															name="operatorInfoModel.operatorId"
															value="<c:out value='${operatorInfoModel.operatorId}'/>">
																<INPUT name="companyName"
																class="txtbox_cz txtbox_cz_color input_change"
																id="companyName" type="text"
																value="<c:out value='${agentInfoModel.companyName}'/>">
																	<span class="reds f_l">*</span> <SPAN
																	class="label cz_label "
																	style="width: 120px; text-align: right;">公司简称：</SPAN> <INPUT
																	name="companyShortName"
																	class="txtbox_cz txtbox_cz_color input_change"
																	id="companyShortName" type="text"
																	value="<c:out value='${agentInfoModel.companyShortName}'/>">
																		<span class="reds f_l">*</span>
													</DIV>
													<DIV class="clearfix" id="personInfo">
														<SPAN class="label cz_label "
															style="width: 120px; text-align: right;">姓名：</SPAN> <INPUT
															name="agentName"
															class="txtbox_cz txtbox_cz_color input_change"
															id="agentName" type="text"
															value="<c:out value='${agentInfoModel.agentName}'/>">
															<span class="reds f_l">*</span> <SPAN
															class="label cz_label "
															style="width: 120px; text-align: right;">证件编号：</SPAN> <INPUT
															name="identityNo"
															class="txtbox_cz txtbox_cz_color input_change"
															id="identityNo" type="text"
															value="<c:out value='${agentInfoModel.identityNo}'/>">
																<span class="reds f_l">*</span>
													</DIV>
													<DIV class="clearfix"></DIV>
													<DIV class="clearfix">
														<SPAN class="label cz_label "
															style="width: 120px; text-align: right;">联系人：</SPAN> <INPUT
															name="contacts"
															class="txtbox_cz txtbox_cz_color input_change"
															id="contacts" type="text"
															value="<c:out value='${agentInfoModel.contacts}'/>">
															<span class="reds f_l">*</span> <SPAN
															class="label cz_label "
															style="width: 120px; text-align: right;">手机：</SPAN> <INPUT
															name="mobilephone"
															class="txtbox_cz txtbox_cz_color input_change"
															id="mobilephone" type="text"
															value="<c:out value='${agentInfoModel.mobilephone}'/>">
																<span class="reds f_l">*</span>
													</DIV>
													<DIV class="clearfix"></DIV>
													<DIV class="clearfix">
														<SPAN class="label cz_label "
															style="width: 120px; text-align: right;">联系电话：</SPAN> <INPUT
															name="telephone" class="txtbox_cz txtbox_cz_color input_change"
															id="telephone" type="text" value="<c:out value='${agentInfoModel.telephone}'/>">
														<span class="reds f_l">*</span>
														<SPAN class="label cz_label "
															style="width: 120px; text-align: right;">邮箱：</SPAN> <INPUT
															name="email" class="txtbox_cz txtbox_cz_color input_change" id="email"
															type="text" value="<c:out value='${agentInfoModel.email}'/>">
													</DIV>

													<DIV class="clearfix"></DIV>
													<DIV class="clearfix">
														<SPAN class="label cz_label "
															style="width: 120px; text-align: right;">系统账号：</SPAN> <INPUT
															name="sysAccount"
															class="txtbox_cz txtbox_cz_color input_change"
															id="sysAccount" type="text"
															value="<c:out value='${agentInfoModel.sysAccount}'/>" placeholder="必须与注册手机号一致！">
															<span class="reds f_l">*</span>
													</DIV>
													<DIV class="clearfix"></DIV>
													<DIV class="clearfix">
														<SPAN class="label cz_label"
															style="width: 120px; text-align: right;">运营起始：</SPAN> <SPAN
															class="label dl_w"
															style="padding-left: 0px; text-align: center; height: 30px; width: 230px;">
															<DIV class="select2 date">
																<INPUT name="bussBegindate"
																	class="easyui-datebox" id="bussBegindate"
																	style="border: none" type="text"
																	data-options="formatter:myformatter,parser:myparser"
																	value="<fmt:formatDate value='${agentInfoModel.bussBegindate}' type='date'/>">
															</DIV> </SPAN> <span class="reds f_l">*</span> <SPAN
															class="label cz_label"
															style="width: 120px; text-align: right;">运营终止:</SPAN> <SPAN
															class="label dl_w"
															style="padding-left: 0px; text-align: center; height: 30px; width: 230px;">
															<DIV class="select2 date">
																<INPUT name="bussEnddate"
																	class="easyui-datebox" id="bussEnddate"
																	style="border: none" type="text"
																	data-options="formatter:myformatter,parser:myparser"
																	value="<fmt:formatDate value='${agentInfoModel.bussEnddate}' type='date'/>">
															</DIV> </SPAN> <span class="reds f_l">*</span>
													</DIV>

													<DIV class="clearfix"></DIV>
													<DIV class="clearfix" id="personImg" name="fileDiv">
														<SPAN class="label cz_label "
															style="width: 120px; text-align: right;">身份证正面：</SPAN>
															<IMG  id="IdcardPhoto" width="400" height="200"  alt="身份证正面"  style="cursor:pointer"
																				src="<%=request.getContextPath()%>/uploadFile/${agentInfoModel.legalIndentityImg}"/>
														    <br/>
														    <span class="span1 label cz_label" style="width:120px;">&nbsp;&nbsp;&nbsp;&nbsp;</span>
														    <input type="file" name="file" id="legalIndentityImg" class="ehdel_upload_text" value="请选择文件"
															   style="height: 31px; margin: 1px 0 0 0;; width: 280px;" />
														    <%--<Button id="uploadImg">上传</Button>--%>
														<span class="reds">*</span>
													</DIV>

													<%--<DIV class="clearfix" id="file1Div" name="fileDiv">
																							<SPAN class="label cz_label "
																								  style="width:120px;text-align:right;">身份证和信用卡：</SPAN>
														<IMG width="300" height="400" alt="身份证和信用卡" style="cursor:pointer"
															 src="${_LOGONUSER_.IMAGESETTLEPATH}/${model.merchantInfoModel.sysAccount}/${model.merchantCertificateInfo.legalIndentityImg}">
														<br>
														<span class="label cz_label " style="width:120px;">&nbsp;&nbsp;&nbsp;&nbsp;</span>
														<input id="file1" type="file" name="file"
															   value="${_LOGONUSER_.IMAGESETTLEPATH}/${model.merchantInfoModel.sysAccount}/${model.merchantCertificateInfo.legalIndentityImg}"
															   style="height:31px;margin:1px 0 0 0;;width:280px;"/>
														<span class="reds">*</span>
													</DIV>--%>


													<DIV class="clearfix" id="companyImg" name="fileDiv">
														<SPAN class="label cz_label "
															style="width: 120px; text-align: right;">营业执照正面：</SPAN>
														  <IMG id="BussinessPhoto" width="400" height="200"  alt="营业执照正面"  style="cursor:pointer"
															  src="<%=request.getContextPath()%>/uploadFile/${agentInfoModel.bussinessImg}">
														   <br/>
														<span class="span2 label cz_label" style="width:120px;">&nbsp;&nbsp;&nbsp;&nbsp;</span>
														<input
																type="file" name="file"
																id="bussinessImg" class="ehdel_upload_text" value="请选择文件"
																style="height: 31px; margin: 1px 0 0 0;; width: 280px;" />
														<%--<Button id="uploadPic">上传</Button>--%>
													</DIV>
													<DIV class="clearfix"></DIV>
													<DIV class="clearfix" id="settleCardFile" name="fileDiv">
														<DIV class="clearfix">
															<SPAN class="label cz_label "
																style="width: 120px; text-align: right;">结算银行卡正面：</SPAN>
															<IMG id="SettleCardPhoto" width="400" height="200"  alt="结算银行卡正面"  style="cursor:pointer"
																  src="<%=request.getContextPath()%>/uploadFile/${agentInfoModel.settleCardImg}">
															<br/>
															<span class="span3 label cz_label" style="width:120px;">&nbsp;&nbsp;&nbsp;&nbsp;</span>
															<input id="settleCardImg" type="file" name="file" value="请选择文件"
																   style="height: 31px; margin: 1px 0 0 0;; width: 280px;" />
															<%--<Button id="uploadPho">上传</Button>--%>
														</DIV>
													</DIV>
													<DIV class="clearfix"></DIV>
													<DIV class="clearfix">
														<SPAN class="label cz_label "
															style="width: 120px; text-align: right;">备注：</SPAN> <INPUT
															name="remark"
															class="txtbox_cz txtbox_cz_color input_change" id="remark" type="text"
															 value="<c:out value='${agentInfoModel.remark}'/>"
															> <span class="label">*如果是城市运营商 需要在此标注*</span>
													</DIV>
													<DIV class="clearfix"></DIV>
													<DIV class="note">
														<SPAN class="label cz_label">&nbsp;</SPAN>
														<A class="btn confirm" href="javascript:void(0);" style="margin-left: 114px;"
														  onclick="javaScript:editAgentInfo('<c:out value="${agentInfoModel.agentId}"/>');">提交</A>
														<A class="btn confirm" href="javascript:void(0);" onclick="javaScript:resetForm();">重置</A>
													</DIV>
												</DIV>
											</FORM>
											<!--当中内容块结束-->
										</div></TD>
								</TR>
							</TABLE></TD>
					</TR>
				</TBODY>
			</TABLE>
		</DIV>
		<%@ include file="/jsp/platform/include/foot.jsp"%>
		<script type="text/javascript">
			debugger;
            var sysAccount = $("#sysAccount").val();
            //var IdcardPhoto = $("#IdcardPhoto").val();
            var iDiv = document.getElementById("IdcardPhoto");
            var bDiv = document.getElementById("BussinessPhoto");
            var sDiv = document.getElementById("SettleCardPhoto");
            var $span1 = $(".span1");
            var $span2 = $(".span2");
            var $span3 = $(".span3");
            if(sysAccount != ""){
                //$("#sysAccount").attr("readonly":readonly);
                $("#sysAccount").attr({readonly:'true'});
                $(".f_tit1").text("编辑代理信息");
                $("#sysPassword").attr({readonly:'true'});
                //$("input[type="text"]").attr("readonly":"readonly");
            }else{
                iDiv.style.display = 'none';
                bDiv.style.display = 'none';
                sDiv.style.display = 'none';
                $span1.hide();
                $span2.hide();
                $span3.hide();
			}


			function dealAgentType()
			{
				var _agentType = $("#agentType").val();
				if (_agentType == "1") {
					$("div[id*='person']").each(function(i) {
						$(this).show();
					});
					$("div[id*='company']").each(function(i) {
						$(this).hide();
					});
				} else if (_agentType == "2") {
					$("div[id*='person']").each(function(i) {
						$(this).hide();
					});
					$("div[id*='company']").each(function(i) {
						$(this).show();
					});
				}
			}
			$("#agentType").change(function() {
				dealAgentType();
			});
			//这句放到页面最后 edit by wenjw 2015.6.2
			$("#agentType").val("<c:out value='${agentInfoModel.agentType}'/>");
			$("#agentLevel").val("<c:out value='${agentInfoModel.agentLevel}'/>");
			dealAgentType();
            debugger;
            var massageStr = getQueryString('msg');
			 if(massageStr!=null && massageStr.length>0){
			     if(massageStr=='1') {
			         showMessage('保存成功');
				 }else{
                     showMessage('保存失败');
				 }

			}

            function getQueryString(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
                var r = window.location.search.substr(1).match(reg);
                var valies=encodeURI(r[2]);
                valies=encodeURI(valies);
                if (r != null) return valies; return null;
            }
		</script>
		<%--<SCRIPT src="<%=request.getContextPath()%>/script/jquery.form.js" type="text/javascript"></SCRIPT>--%>
</BODY>
</HTML>
